Skip to content

Fix dropped netlink messages when too many for the buffer#1

Open
refi64 wants to merge 1 commit intodklibc:masterfrom
refi64:fix-overflow
Open

Fix dropped netlink messages when too many for the buffer#1
refi64 wants to merge 1 commit intodklibc:masterfrom
refi64:fix-overflow

Conversation

@refi64
Copy link

@refi64 refi64 commented Jan 2, 2023

Because the buffer size is a fixed 4kb, if a netlink message is truncated, only some parts of it would end up in the buffer, leading to the message being dropped. Instead, peek at the message size ahead via MSG_PEEK|MSG_TRUNC and allocate a buffer to fit it dynamically. (AFAIK netlink messages can be >4kb anyway, so this is a bit more generally useful.)

Because the buffer size is a fixed 4kb, if a netlink message is
truncated, only some parts of it would end up in the buffer, leading to
the message being dropped. Instead, peek at the message size ahead via
MSG_PEEK|MSG_TRUNC and allocate a buffer to fit it dynamically. (AFAIK
netlink messages can be >4kb anyway, so this is a bit more generally
useful.)
@troglobit
Copy link

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants